package com.idealighter.game.games.shuihu.struct;

/**
 * :水浒难度 .
 * 
 * <ul>
 * .
 * <li>1 . tf 铁斧</li>
 * <li>2 . yq 银枪</li>
 * <li>3 . jd 金刀</li>
 * <li>4 . lzs 鲁智深</li>
 * <li>5 . lc 林冲</li>
 * <li>6 . sj 宋江</li>
 * <li>7 . ttxd 替天行道</li>
 * <li>8 . zyt 忠义堂</li>
 * <li>9 . shz 水浒传</li>
 * </ul>
 * .
 * 
 * 
 * @date 2015年11月9日 下午5:53:11
 *
 */
public enum ShuiHuDifficulty {
  /**
   * HARDEST . 最难.50.
   */
  HARDEST(-2, "最难", new int[] { 4000, 1600, 1500, 2000, 1500, 1500, 500, 500, 50 }),
  /**
   * DIFFICULT . 困难.
   */
  DIFFICULT(-1, "困难", new int[] { 5500, 1600, 1500, 3000, 1500, 1500, 500, 500, 100 }),
  /**
   * 普通.
   */
  NORMAL(0, "普通", new int[] { 5500, 1600, 1500, 3000, 1500, 1500, 500, 500, 700 }),
  /**
   * 简单.
   */
  EASY(1, "简单", new int[] { 5500, 1600, 1500, 3000, 1500, 1500, 500, 500, 1300 }),
  /**
   * 轻松.
   */
  EASIEST(2, "轻松", new int[] { 1600, 5500, 1500, 3000, 1500, 1500, 500, 500, 1300 });



  // 难度
  private final int difficulty;
  // 名称
  private final String name;
  // 权重
  private final int[] weights;

  public int getDifficulty() {
    return difficulty;
  }

  public String getName() {
    return name;
  }

  public int[] getWeights() {
    return weights;
  }

  /**
   * 构造函数 .
   * 
   * @param difficulty 难度.
   * @param weights 权重列表.
   */
  private ShuiHuDifficulty(int difficulty, String name, int[] weights) {
    this.difficulty = difficulty;
    this.name = name;
    this.weights = weights;
  }

  /**
   * 权重和.
   * 
   * @return 权重和.
   */
  public int totalWeight() {
    int totalWeight = 0;
    for (int weight : weights) {
      totalWeight += weight;
    }

    return totalWeight;
  }

  /**
   * 获取难度.
   * 
   * @param difficulty 难度值.
   * @return 难度》
   */
  public static ShuiHuDifficulty get(int difficulty) {
    for (ShuiHuDifficulty d : values()) {
      if (d.difficulty == difficulty) {
        return d;
      }
    }

    return null;
  }

}
